package com.telchina.device.controller;

import com.alibaba.fastjson2.JSON;
import com.telchina.common.core.text.Convert;
import com.telchina.device.entity.TDeviceManage;
import com.telchina.device.service.ITDeviceManageService;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.telchina.common.annotation.Log;
import com.telchina.common.core.controller.BaseController;
import com.telchina.common.core.domain.AjaxResult;
import com.telchina.common.enums.BusinessType;


/**
 * 设备表控制层
 *
 * @author 郝振
 * @since 2023-06-19 11:22:53
 */
@RestController
@RequestMapping("/device/deviceManage")
public class TDeviceManageController extends BaseController{
    /**
     * 服务对象
     */
   
	private final ITDeviceManageService tDeviceManageService;

    @Autowired
    public TDeviceManageController(ITDeviceManageService tDeviceManageService) {
        this.tDeviceManageService = tDeviceManageService;
    }
    /**
     * 分页查询
     *
     * @param tDeviceManage 筛选条件
     */
     @GetMapping("/list")
     public AjaxResult list(TDeviceManage tDeviceManage) {
        startPage();
        List<TDeviceManage> list = tDeviceManageService.selectTDeviceManageList(tDeviceManage);
        return AjaxResult.success(list);
     }
    /**
     * 获取详情
     *
     */
    @GetMapping("/getInfo")
    public AjaxResult getInfo(String id) {
        return AjaxResult.success(tDeviceManageService.getById(id));
    }
   
    /**
     * 新增
     *
     * @param tDeviceManage 实体
     */
	@Log(title = "管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@Validated @RequestBody TDeviceManage tDeviceManage){
        return toAjax(tDeviceManageService.save(tDeviceManage));
    }
	
    /**
     * 编辑
     *
     * @param tDeviceManage 实体
     */
    @Log(title = "", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@Validated @RequestBody TDeviceManage tDeviceManage){
        return toAjax(tDeviceManageService.updateById(tDeviceManage));
    }

    /**
     * 删除
     *
     * @param ids 主键
     */
	@Log(title = "", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete")
    public AjaxResult delete(@RequestBody String ids){
        return success(tDeviceManageService.removeByIds(JSON.parseObject(ids, List.class)));
    }
	

}

